From: Andreas Beckmann <debian@abeckmann.de>
Subject: simplify path overflow error handling
 "path too long" is not a fatal error, there may be other search paths
 that don't overflow, so try them as well

--- a/src/vdpau_wrapper.c
+++ b/src/vdpau_wrapper.c
@@ -132,6 +132,8 @@ static VdpStatus _vdp_open_driver(
         vdpau_driver = "nvidia";
     }
 
+    _vdp_driver_dll = NULL;
+
     /* Don't allow setuid apps to use VDPAU_DRIVER_PATH */
     vdpau_driver_path = secure_getenv("VDPAU_DRIVER_PATH");
     if (vdpau_driver_path &&
@@ -141,12 +143,6 @@ static VdpStatus _vdp_open_driver(
                      DRIVER_LIB_FORMAT, VDPAU_MODULEDIR, vdpau_driver) >=
                 sizeof(vdpau_driver_lib)) {
             fprintf(stderr, "Failed to construct driver path: path too long\n");
-            if (vdpau_driver_dri2) {
-                XFree(vdpau_driver_dri2);
-                vdpau_driver_dri2 = NULL;
-            }
-            _VDP_ERROR_BREAKPOINT();
-            return VDP_STATUS_NO_IMPLEMENTATION;
         }
         else {
             _vdp_driver_dll = dlopen(vdpau_driver_lib, RTLD_NOW | RTLD_GLOBAL);
@@ -154,11 +150,12 @@ static VdpStatus _vdp_open_driver(
     }
 
     if (!_vdp_driver_dll) {
-        /* Try again using the old path, which is guaranteed to fit in PATH_MAX
-         * if the complete path fit above. */
-        snprintf(vdpau_driver_lib, sizeof(vdpau_driver_lib),
-                 DRIVER_FALLBACK_LIB_FORMAT, vdpau_driver);
-        _vdp_driver_dll = dlopen(vdpau_driver_lib, RTLD_NOW | RTLD_GLOBAL);
+        /* Try again using the old path. */
+        if (snprintf(vdpau_driver_lib, sizeof(vdpau_driver_lib),
+                     DRIVER_FALLBACK_LIB_FORMAT, vdpau_driver) <
+                sizeof(vdpau_driver_lib)) {
+            _vdp_driver_dll = dlopen(vdpau_driver_lib, RTLD_NOW | RTLD_GLOBAL);
+        }
     }
 
     if (vdpau_driver_dri2) {
